package com.xxxxx.Servlet;

import java.io.IOException;


import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/*
 * 实现Servlet
 *  1. 创建普通的java类
 *  2. 实现Servlet的规范,继承httpServlet类
 *  3. 重写Service方法,用来处理请求
 *  4. 设置注释,指定访问路径
 */

@WebServlet("/s1")
public class TestServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//将内容打印到Servers页面
		System.out.println("Hello Servlet! ");
		//将内容打印到浏览器页面
		response.getWriter().write("Hello Servlet");
	}
	
}
